Skip to content

Commit

Permalink
style: 💄 format tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisermann committed Nov 5, 2020
1 parent cddd0c9 commit 940aa65
Show file tree
Hide file tree
Showing 8 changed files with 394 additions and 380 deletions.
12 changes: 11 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,15 @@
},
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
},
"overrides": [
{
"files": ["test/**/*"],
"rules": {
"global-require": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-require-imports": "off"
}
}
]
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"test": "jest",
"test:ci": "jest --silent",
"test:watch": "jest --verbose --watchAll",
"lint": "eslint \"src/**/*.ts\"",
"format": "prettier --loglevel silent --write \"src/**/*.ts\"",
"lint": "eslint \"{src,test}/**/*.ts\"",
"format": "prettier --loglevel silent --write \"{src,test}/**/*.ts\"",
"release": " git add package.json && git commit -m \"chore(release): v$npm_package_version :tada:\"",
"pretest": "npm run build",
"prebuild": "yarn clean",
Expand Down
42 changes: 21 additions & 21 deletions test/runtime/configs.test.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
import { get } from 'svelte/store'
import { get } from 'svelte/store';

import {
init,
getOptions,
defaultOptions,
defaultFormats,
} from '../../src/runtime/configs'
import { $locale } from '../../src/runtime/stores/locale'
} from '../../src/runtime/configs';
import { $locale } from '../../src/runtime/stores/locale';

beforeEach(() => {
init(defaultOptions)
})
init(defaultOptions);
});

test('inits the fallback locale', () => {
expect(getOptions().fallbackLocale).toBe(null)
expect(getOptions().fallbackLocale).toBeNull();
init({
fallbackLocale: 'en',
})
expect(getOptions().fallbackLocale).toBe('en')
})
});
expect(getOptions().fallbackLocale).toBe('en');
});

test('inits the initial locale by string', () => {
init({
fallbackLocale: 'pt',
initialLocale: 'en',
})
expect(getOptions().initialLocale).toBe('en')
expect(get($locale)).toBe('en')
})
});
expect(getOptions().initialLocale).toBe('en');
expect(get($locale)).toBe('en');
});

test('adds custom formats for time, date and number values', () => {
const customFormats = require('../fixtures/formats.json')
const customFormats = require('../fixtures/formats.json');

init({
fallbackLocale: 'en',
formats: customFormats,
})
expect(getOptions().formats).toMatchObject(defaultFormats)
expect(getOptions().formats).toMatchObject(customFormats)
})
});
expect(getOptions().formats).toMatchObject(defaultFormats);
expect(getOptions().formats).toMatchObject(customFormats);
});

test('sets the minimum delay to set the loading store value', () => {
init({ fallbackLocale: 'en', loadingDelay: 300 })
expect(getOptions().loadingDelay).toBe(300)
})
init({ fallbackLocale: 'en', loadingDelay: 300 });
expect(getOptions().loadingDelay).toBe(300);
});
Loading

0 comments on commit 940aa65

Please sign in to comment.