2017-10-31 12:15:03 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
import subscriptions from '~/sidebar/components/subscriptions/subscriptions.vue';
|
|
|
|
import mountComponent from '../helpers/vue_mount_component_helper';
|
|
|
|
|
|
|
|
describe('Subscriptions', function () {
|
|
|
|
let vm;
|
|
|
|
let Subscriptions;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
Subscriptions = Vue.extend(subscriptions);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows loading spinner when loading', () => {
|
|
|
|
vm = mountComponent(Subscriptions, {
|
|
|
|
loading: true,
|
|
|
|
subscribed: undefined,
|
|
|
|
});
|
|
|
|
|
2018-01-12 00:45:54 -05:00
|
|
|
expect(vm.$refs.toggleButton.isLoading).toBe(true);
|
|
|
|
expect(vm.$refs.toggleButton.$el.querySelector('.project-feature-toggle')).toHaveClass('is-loading');
|
2017-10-31 12:15:03 -04:00
|
|
|
});
|
|
|
|
|
2018-01-12 00:45:54 -05:00
|
|
|
it('is toggled "off" when currently not subscribed', () => {
|
2017-10-31 12:15:03 -04:00
|
|
|
vm = mountComponent(Subscriptions, {
|
|
|
|
subscribed: false,
|
|
|
|
});
|
|
|
|
|
2018-01-12 00:45:54 -05:00
|
|
|
expect(vm.$refs.toggleButton.$el.querySelector('.project-feature-toggle')).not.toHaveClass('is-checked');
|
2017-10-31 12:15:03 -04:00
|
|
|
});
|
|
|
|
|
2018-01-12 00:45:54 -05:00
|
|
|
it('is toggled "on" when currently subscribed', () => {
|
2017-10-31 12:15:03 -04:00
|
|
|
vm = mountComponent(Subscriptions, {
|
|
|
|
subscribed: true,
|
|
|
|
});
|
|
|
|
|
2018-01-12 00:45:54 -05:00
|
|
|
expect(vm.$refs.toggleButton.$el.querySelector('.project-feature-toggle')).toHaveClass('is-checked');
|
2017-10-31 12:15:03 -04:00
|
|
|
});
|
|
|
|
});
|