(Single, setGlobals, titlePrefix = '')
| 3 | import { UrlNotSupportedError } from '../../../src/_provider/Errors'; |
| 4 | |
| 5 | export function generalSingleTests(Single, setGlobals, titlePrefix = '') { |
| 6 | describe('Url', function() { |
| 7 | describe('Constructor', function() { |
| 8 | global.testData.urlTest.forEach(el => { |
| 9 | it(el.url, function() { |
| 10 | if (!el.error) { |
| 11 | let single; |
| 12 | expect(() => (single = new Single(el.url))).not.to.throw(); |
| 13 | expect(single.getType()).equal(el.type); |
| 14 | } else { |
| 15 | expect(() => new Single(el.url)) |
| 16 | .to.throw(UrlNotSupportedError); |
| 17 | } |
| 18 | }); |
| 19 | }); |
| 20 | }); |
| 21 | }); |
| 22 | |
| 23 | describe('Dry', function() { |
| 24 | const singleEntry = new Single(global.testData.urlTest[0].url); |
| 25 | before(async function() { |
| 26 | this.timeout(50000); |
| 27 | await singleEntry.update(); |
| 28 | }); |
| 29 | |
| 30 | describe('Status', function() { |
| 31 | [ |
| 32 | def.status.Watching, |
| 33 | def.status.Completed, |
| 34 | def.status.Onhold, |
| 35 | def.status.Dropped, |
| 36 | def.status.PlanToWatch, |
| 37 | def.status.Rewatching, |
| 38 | def.status.Considering, |
| 39 | ].forEach(el => { |
| 40 | it(def.status[el], function() { |
| 41 | singleEntry.setStatus(el); |
| 42 | if ( |
| 43 | el === def.status.Rewatching && |
| 44 | !singleEntry.supportsRewatching() |
| 45 | ) { |
| 46 | expect(singleEntry.getStatus()).equal(def.status.Watching); |
| 47 | } else if ( |
| 48 | el === def.status.Considering && |
| 49 | !singleEntry.supportsConsidering() |
| 50 | ) { |
| 51 | expect(singleEntry.getStatus()).equal(def.status.PlanToWatch); |
| 52 | } else { |
| 53 | expect(singleEntry.getStatus()).equal(el); |
| 54 | } |
| 55 | }); |
| 56 | }); |
| 57 | }); |
| 58 | |
| 59 | describe('Score', function() { |
| 60 | [ |
| 61 | def.score.NoScore, |
| 62 | def.score.R1, |
no test coverage detected