2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 15:50:56 +00:00
books/tests/test_naming.js

24 lines
959 B
JavaScript
Raw Normal View History

2018-03-05 16:45:21 +00:00
const assert = require('assert');
const frappe = require('frappejs');
const helpers = require('./helpers');
const naming = require('frappejs/model/naming')
describe('Naming', () => {
before(async function() {
await helpers.initSqlite();
});
it('should start a series and get next value', async () => {
frappe.db.delete('NumberSeries', 'test-series-')
2018-07-17 19:29:18 +00:00
assert.equal(await naming.getSeriesNext('test-series-'), 'test-series-1001');
assert.equal(await naming.getSeriesNext('test-series-'), 'test-series-1002');
assert.equal(await naming.getSeriesNext('test-series-'), 'test-series-1003');
2018-03-05 16:45:21 +00:00
});
it('should set name by autoincrement', async () => {
const todo1 = await frappe.insert({doctype: 'ToDo', subject: 'naming test'});
const todo2 = await frappe.insert({doctype: 'ToDo', subject: 'naming test'});
assert.equal(parseInt(todo1.name) + 1, parseInt(todo2.name));
});
});