2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-27 10:51:33 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2018-12-18 14:43:23 +00:00
|
|
|
import { mount, shallowMount } from '@vue/test-utils';
|
2019-01-28 18:20:33 +00:00
|
|
|
import AccountDropdown from '@/components/header/AccountDropdown.vue';
|
2018-11-16 14:28:02 +00:00
|
|
|
import * as sinon from 'sinon';
|
|
|
|
|
|
|
|
describe('AccountDropdown.vue', () => {
|
2018-12-18 14:43:23 +00:00
|
|
|
|
2018-11-16 14:28:02 +00:00
|
|
|
it('renders correctly', () => {
|
|
|
|
|
2018-12-18 14:43:23 +00:00
|
|
|
const wrapper = shallowMount(AccountDropdown);
|
2018-11-16 14:28:02 +00:00
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
2018-12-18 14:43:23 +00:00
|
|
|
});
|
|
|
|
|
2018-11-16 14:28:02 +00:00
|
|
|
it('trigger onPress correctly', () => {
|
|
|
|
let onCloseSpy = sinon.spy();
|
|
|
|
|
|
|
|
const wrapper = mount(AccountDropdown, {
|
|
|
|
propsData: {
|
|
|
|
onClose: onCloseSpy
|
|
|
|
},
|
|
|
|
mocks: {
|
|
|
|
$router: {
|
|
|
|
push: onCloseSpy
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
wrapper.find('.adItemContainer.settings').trigger('click');
|
2018-12-18 14:43:23 +00:00
|
|
|
|
2018-11-16 14:28:02 +00:00
|
|
|
expect(onCloseSpy.callCount).toBe(1);
|
2018-12-18 14:43:23 +00:00
|
|
|
expect(wrapper.emitted('onClose').length).toEqual(1);
|
2018-11-16 14:28:02 +00:00
|
|
|
});
|
2018-12-18 14:43:23 +00:00
|
|
|
});
|