UNPKG

2.23 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6const ava_1 = __importDefault(require("ava"));
7const config_1 = require("../../src/config");
8const createRoarrInitialGlobalState_1 = require("../../src/factories/createRoarrInitialGlobalState");
9(0, ava_1.default)('creates new state', (t) => {
10 const state = (0, createRoarrInitialGlobalState_1.createRoarrInitialGlobalState)({});
11 t.like(state, {
12 sequence: 0,
13 versions: [
14 config_1.ROARR_VERSION,
15 ],
16 });
17});
18(0, ava_1.default)('respects existing sequence', (t) => {
19 const state = (0, createRoarrInitialGlobalState_1.createRoarrInitialGlobalState)({
20 sequence: 1,
21 });
22 t.like(state, {
23 sequence: 1,
24 versions: [
25 config_1.ROARR_VERSION,
26 ],
27 });
28});
29(0, ava_1.default)('appends the latest version', (t) => {
30 const state = (0, createRoarrInitialGlobalState_1.createRoarrInitialGlobalState)({
31 versions: [
32 '0.0.1',
33 ],
34 });
35 t.like(state, {
36 sequence: 0,
37 versions: [
38 '0.0.1',
39 config_1.ROARR_VERSION,
40 ],
41 });
42});
43(0, ava_1.default)('sets "write" method if current is the first version', (t) => {
44 const state = (0, createRoarrInitialGlobalState_1.createRoarrInitialGlobalState)({});
45 t.is(typeof state.write, 'function');
46});
47(0, ava_1.default)('overrides "write" method if current is the latest version', (t) => {
48 const state = (0, createRoarrInitialGlobalState_1.createRoarrInitialGlobalState)({
49 versions: [
50 '0.0.1',
51 ],
52 write: 'foo',
53 });
54 t.is(typeof state.write, 'function');
55});
56(0, ava_1.default)('does not override "write" method if current is not the latest version', (t) => {
57 // eslint-disable-next-line @typescript-eslint/no-empty-function
58 const write = () => { };
59 const state = (0, createRoarrInitialGlobalState_1.createRoarrInitialGlobalState)({
60 versions: [
61 '100.0.0',
62 ],
63 write,
64 });
65 t.is(state.write, write);
66});