Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('builds plural entry with context from call expression', () => {
const path = {
node: {
callee: { name: '_nc' },
arguments: [
{ value: 'One' },
{ value: 'Many' },
{ value: 10 },
{ value: 'Some context' },
],
},
}
expect(buildCallExpressionEntry(types, path, state)).toEqual({
msgid: 'One',
msgid_plural: 'Many',
msgctxt: 'Some context',
})
})
it('plural entry contains 2 msgstr', () => {
const result = mergeEntries({}, [{
msgid_plural: 'Many',
msgid: 'One',
}])
expect(result.translations[''].One.msgstr).toEqual(['', ''])
})
it('includes default charset and headers if included', () => {
const charset = 'UTF-8'
const expectedHeaders = {
'content-type': 'text/plain; charset=UTF-8',
'plural-forms': 'nplurals=2; plural=(n!=1);',
language: 'en_US',
}
const result = mergeEntries({}, [])
expect(result.charset).toEqual(charset)
expect(result.headers).toEqual(expectedHeaders)
})
it('strips up to base directory from reference if found', () => {
const result = buildReference(
{ msgid: 'Hello' },
Object.assign({}, state, {
opts: {
includeReference: true,
baseDir: 'project',
},
}))
expect(result.reference).toBe('js/code.js')
})
expect(() => {
const entry = buildCallExpressionEntry(types, path, Object.assign({}, state, {
opts: {
function: [
{
type: 'SINGULAR',
name: '_',
singular: 0,
ignoreError: true,
},
],
},
}))
expect(entry).toBeUndefined()
}).not.toThrow()
})
expect(() => buildCallExpressionEntry(types, path, state)).toThrow(/string literal/i)
})
value: { value: 'Context' },
}, {
name: { name: 'comment' },
value: { value: 'On homepage' },
}, {
name: { name: 'numFriends' },
value: { value: '10,000' },
}, {
name: { name: 'count' },
value: { value: 10000 },
}],
},
},
}
expect(buildJSXElementEntry(types, path, state)).toEqual({
msgid: 'You have one friend!',
msgid_plural: 'You have {numFriends} friends!',
msgctxt: 'Context',
extracted: 'On homepage',
})
})
xit('should match sort the builders by tag groups', function() {
createController();
const _builders = FIXTURES['builders.fixture.json'].builders;
for (let builder of Array.from(_builders)) {
builder.hasBuild = true;
}
scope.c.sortBuildersByTags(_builders);
expect(_builders.length).toBe(scope.c.builders.length);
expect(scope.c.tag_lines.length).toEqual(5);
});
});