mirror of https://gitgud.io/fatchan/jschan.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.7 KiB
35 lines
1.7 KiB
2 years ago
|
const name = require('./name.js');
|
||
|
const Permission = require('../permission.js')
|
||
|
const Permissions = require('../permissions.js')
|
||
|
const ROOT = new Permission();
|
||
|
ROOT.setAll(Permission.allPermissions);
|
||
2 years ago
|
const NO_PERMISSION = new Permission();
|
||
2 years ago
|
|
||
|
describe('name/trip/capcode handler', () => {
|
||
|
|
||
|
const cases = [
|
||
|
{ in: '## Admin', out: { name: 'Anon', tripcode: null, capcode: '## Admin' } },
|
||
|
{ in: '## Global Staff', out: { name: 'Anon', tripcode: null, capcode: '## Global Staff' } },
|
||
|
{ in: '## Board Owner', out: { name: 'Anon', tripcode: null, capcode: '## Admin' } },
|
||
|
{ in: '## Board Mod', out: { name: 'Anon', tripcode: null, capcode: '## Admin' } },
|
||
|
{ in: '##', out: { name: 'Anon', tripcode: null, capcode: '## Admin' } },
|
||
|
{ in: '', out: { name: 'Anon', tripcode: null, capcode: null } },
|
||
|
{ in: 'test', out: { name: 'test', tripcode: null, capcode: null } },
|
||
|
{ in: 'test#12345', out: { name: 'test', tripcode: '!CSZ6G0yP9Q', capcode: null } },
|
||
|
{ in: '#12345', out: { name: 'Anon', tripcode: '!CSZ6G0yP9Q', capcode: null } },
|
||
|
{ in: '#12345## Admin', out: { name: 'Anon', tripcode: '!CSZ6G0yP9Q', capcode: '## Admin' } },
|
||
2 years ago
|
{ in: '###########', perm: NO_PERMISSION, out: { name: 'Anon', tripcode: '!!AR2Fv1lg4=', capcode: null } },
|
||
|
{ in: '##test', out: { name: 'Anon', tripcode: '!!4XzKAGoCE=', capcode: null } },
|
||
2 years ago
|
{ in: 'test#12345## Admin', out: { name: 'test', tripcode: '!CSZ6G0yP9Q', capcode: '## Admin' } },
|
||
|
];
|
||
|
|
||
|
for(let i in cases) {
|
||
|
test(`should contain ${cases[i].out.capcode} for an input of ${cases[i].in}`, async () => {
|
||
2 years ago
|
const output = await name(cases[i].in, (cases[i].perm || ROOT), {forceAnon: false, defaultName: 'Anon'}, 'a', {a:ROOT}, 'b')
|
||
2 years ago
|
expect(output).toStrictEqual(cases[i].out)
|
||
|
});
|
||
|
}
|
||
|
|
||
|
|
||
|
});
|