| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import test from 'ava'
- import { Login } from '../src/services/login.service.js'
-
- test('Make sure we can instantiate login service', async t => {
- const currentProfile = new Login()
-
- t.is(currentProfile.isLoggedIn, false)
- t.is(currentProfile.isComplete, false)
- t.is(currentProfile.hasResponses, 0)
-
- currentProfile.id.value = 99
- currentProfile._loading.value = false
- t.is(currentProfile.isLoggedIn, true)
- })
-
- test('Make sure login.tags can be set', async t => {
- const currentProfile = new Login()
- const testTags = ['x', 'y', 'z']
- currentProfile.setTags(testTags)
- t.is(currentProfile.tags, testTags)
- })
-
- test('Make sure login.responses can be set', async t => {
- const currentProfile = new Login()
- const testResponses = ['100', '200', '300']
- currentProfile.setResponses(testResponses)
- t.is(currentProfile.responses, testResponses)
- })
-
- test('Make sure login.groupings work correctly', async t => {
- const currentProfile = new Login()
- const testGroupings = [
- { name: 'a', is_paired: false },
- { name: 'b', is_paired: false },
- { name: 'c', is_paired: true },
- ]
- currentProfile.groupings = testGroupings
- t.deepEqual(
- currentProfile.pendingGroupings.map(g => g.name),
- ['a', 'b'],
- )
- t.deepEqual(
- currentProfile.pairedGroupings.map(g => g.name),
- ['c'],
- )
- })
-
- test('Make sure login.logout() works', async t => {
- const currentProfile = new Login()
- currentProfile.id.value = 99
-
- currentProfile.toaster = { name: 'dummy_toaster', stop: () => {} }
- currentProfile.chatter = { name: 'dummy_chatter', stop: () => {} }
- t.is(currentProfile.chatter.name, 'dummy_chatter')
-
- currentProfile.logout()
- t.is(currentProfile.id.value, null)
- })
|