Navigation Menu

Skip to content

Commit

Permalink
test: general and single component installation covered (#8)
Browse files Browse the repository at this point in the history
* test: single component installation

* test: general installation
  • Loading branch information
arturmiz committed Jun 4, 2018
1 parent bd56072 commit 67dc36c
Show file tree
Hide file tree
Showing 12 changed files with 222 additions and 78 deletions.
59 changes: 59 additions & 0 deletions __tests__/Vuent.test.js
@@ -0,0 +1,59 @@
import { createLocalVue } from '@vue/test-utils';
import { isInstalled, countInstalledPlugins } from './utils';

import {
VntButton,
VntCheckbox,
VntHeader,
VntInput,
VntLink,
VntRadio,
VntSelect,
VntSlider,
VntToggle
} from '@/components';

import Vuent from '@/';

describe('Vuent', () => {
let localVue;

beforeEach(() => {
localVue = createLocalVue();
});

describe('by default', () => {

beforeEach(() => {
localVue.use(Vuent);
});

test('installs all components', () => {
expect(isInstalled(localVue, VntButton)).toBe(true);
expect(isInstalled(localVue, VntCheckbox)).toBe(true);
expect(isInstalled(localVue, VntHeader)).toBe(true);
expect(isInstalled(localVue, VntInput)).toBe(true);
expect(isInstalled(localVue, VntLink)).toBe(true);
expect(isInstalled(localVue, VntRadio)).toBe(true);
expect(isInstalled(localVue, VntSelect)).toBe(true);
expect(isInstalled(localVue, VntSlider)).toBe(true);
expect(isInstalled(localVue, VntToggle)).toBe(true);
expect(countInstalledPlugins(localVue)).toBe(9);
});

});

describe('when custom configured', () => {

test('installs only given components', () => {
Vuent.install(localVue, {
components: [VntButton, VntLink]
});
expect(isInstalled(localVue, VntButton)).toBe(true);
expect(isInstalled(localVue, VntLink)).toBe(true);
expect(countInstalledPlugins(localVue)).toBe(2);
});

});

});
20 changes: 14 additions & 6 deletions __tests__/button.test.js
@@ -1,13 +1,21 @@
import { mount } from '@vue/test-utils';
import Button from '@/components/button';
import { createLocalVue, mount } from '@vue/test-utils';
import { VntButton } from '@/components';
import { isInstalled } from './utils';

describe('Button', () => {
let wrapper;

test('can be installed separately', () => {
const localVue = createLocalVue();
localVue.use(VntButton);

expect(isInstalled(localVue, VntButton)).toBe(true);
});

describe('by default', () => {

beforeAll(() => {
wrapper = mount(Button);
wrapper = mount(VntButton);
});

test('has correct type', () => {
Expand All @@ -31,7 +39,7 @@ describe('Button', () => {
describe('can be disabled', () => {

beforeAll(() => {
wrapper = mount(Button, {
wrapper = mount(VntButton, {
propsData: {
disabled: true
}
Expand All @@ -49,7 +57,7 @@ describe('Button', () => {
});

test('can have content set using slot', () => {
wrapper = mount(Button, {
wrapper = mount(VntButton, {
slots: {
default: '<span>Custom content</span>'
}
Expand All @@ -59,7 +67,7 @@ describe('Button', () => {

test('when clicked invokes passed handler', () => {
const mockClick = jest.fn();
wrapper = mount(Button, {
wrapper = mount(VntButton, {
propsData: {
click: mockClick
}
Expand Down
26 changes: 17 additions & 9 deletions __tests__/checkbox.test.js
@@ -1,13 +1,21 @@
import { mount } from '@vue/test-utils';
import Checkbox from '@/components/checkbox';
import { createLocalVue, mount } from '@vue/test-utils';
import { VntCheckbox } from '@/components';
import { isInstalled } from './utils';

describe('Checkbox', () => {
let wrapper;

test('can be installed separately', () => {
const localVue = createLocalVue();
localVue.use(VntCheckbox);

expect(isInstalled(localVue, VntCheckbox)).toBe(true);
});

describe('by default', () => {

beforeAll(() => {
wrapper = mount(Checkbox);
wrapper = mount(VntCheckbox);
});

test('is not disabled', () => {
Expand All @@ -31,7 +39,7 @@ describe('Checkbox', () => {
describe('can be disabled', () => {

beforeAll(() => {
wrapper = mount(Checkbox, {
wrapper = mount(VntCheckbox, {
propsData: {
disabled: true
}
Expand All @@ -51,7 +59,7 @@ describe('Checkbox', () => {
describe('can be checked', () => {

beforeAll(() => {
wrapper = mount(Checkbox, {
wrapper = mount(VntCheckbox, {
propsData: {
checked: true
}
Expand All @@ -71,7 +79,7 @@ describe('Checkbox', () => {
describe('can be checked and disabled', () => {

beforeAll(() => {
wrapper = mount(Checkbox, {
wrapper = mount(VntCheckbox, {
propsData: {
checked: true,
disabled: true
Expand All @@ -94,7 +102,7 @@ describe('Checkbox', () => {
});

test('can have content set using slot', () => {
wrapper = mount(Checkbox, {
wrapper = mount(VntCheckbox, {
slots: {
default: '<span>Custom content</span>'
}
Expand All @@ -105,7 +113,7 @@ describe('Checkbox', () => {
describe('when not disabled, updates passed checked prop', () => {

beforeAll(() => {
wrapper = mount(Checkbox, {
wrapper = mount(VntCheckbox, {
propsData: {
checked: false
}
Expand All @@ -129,7 +137,7 @@ describe('Checkbox', () => {
describe('when disabled, doesn\'t change state', () => {

beforeAll(() => {
wrapper = mount(Checkbox, {
wrapper = mount(VntCheckbox, {
propsData: {
checked: false,
disabled: true
Expand Down
22 changes: 15 additions & 7 deletions __tests__/header.test.js
@@ -1,13 +1,21 @@
import { mount } from '@vue/test-utils';
import Header from '@/components/header';
import { createLocalVue, mount } from '@vue/test-utils';
import { VntHeader } from '@/components';
import { isInstalled } from './utils';

describe('Header', () => {
let wrapper;

test('can be installed separately', () => {
const localVue = createLocalVue();
localVue.use(VntHeader);

expect(isInstalled(localVue, VntHeader)).toBe(true);
});

describe('by default', () => {

beforeAll(() => {
wrapper = mount(Header);
wrapper = mount(VntHeader);
});

test('renders correctly', () => {
Expand All @@ -17,7 +25,7 @@ describe('Header', () => {
});

test('can have only main header content set', () => {
wrapper = mount(Header, {
wrapper = mount(VntHeader, {
slots: {
default: 'Header'
}
Expand All @@ -26,7 +34,7 @@ describe('Header', () => {
});

test('can have main header content set using named slot', () => {
wrapper = mount(Header, {
wrapper = mount(VntHeader, {
slots: {
header: 'Header'
}
Expand All @@ -35,7 +43,7 @@ describe('Header', () => {
});

test('can have both header and subheader content set', () => {
wrapper = mount(Header, {
wrapper = mount(VntHeader, {
slots: {
header: 'Header',
subheader: 'Subheader'
Expand All @@ -45,7 +53,7 @@ describe('Header', () => {
});

test('can have only subheader content set', () => {
wrapper = mount(Header, {
wrapper = mount(VntHeader, {
slots: {
subheader: 'Subheader'
}
Expand Down
26 changes: 17 additions & 9 deletions __tests__/input.test.js
@@ -1,13 +1,21 @@
import { mount } from '@vue/test-utils';
import Input from '@/components/input';
import { createLocalVue, mount } from '@vue/test-utils';
import { VntInput } from '@/components';
import { isInstalled } from './utils';

describe('Input', () => {
let wrapper;

test('can be installed separately', () => {
const localVue = createLocalVue();
localVue.use(VntInput);

expect(isInstalled(localVue, VntInput)).toBe(true);
});

describe('by default', () => {

beforeAll(() => {
wrapper = mount(Input);
wrapper = mount(VntInput);
});

test('has correct type', () => {
Expand Down Expand Up @@ -39,7 +47,7 @@ describe('Input', () => {
describe('can be disabled', () => {

beforeAll(() => {
wrapper = mount(Input, {
wrapper = mount(VntInput, {
propsData: {
disabled: true
}
Expand All @@ -59,7 +67,7 @@ describe('Input', () => {
describe('can have a custom label', () => {

beforeAll(() => {
wrapper = mount(Input, {
wrapper = mount(VntInput, {
propsData: {
label: 'Custom label'
}
Expand All @@ -79,7 +87,7 @@ describe('Input', () => {
describe('can be a password field', () => {

beforeAll(() => {
wrapper = mount(Input, {
wrapper = mount(VntInput, {
propsData: {
type: 'password'
}
Expand All @@ -99,7 +107,7 @@ describe('Input', () => {
describe('can have a custom placeholder', () => {

beforeAll(() => {
wrapper = mount(Input, {
wrapper = mount(VntInput, {
propsData: {
placeholder: 'Custom hint'
}
Expand All @@ -119,7 +127,7 @@ describe('Input', () => {
describe('can be fully customized', () => {

beforeAll(() => {
wrapper = mount(Input, {
wrapper = mount(VntInput, {
propsData: {
type: 'number',
label: 'Custom label',
Expand All @@ -138,7 +146,7 @@ describe('Input', () => {
describe('updates passed value', () => {

beforeAll(() => {
wrapper = mount(Input, {
wrapper = mount(VntInput, {
propsData: {
value: '12345'
}
Expand Down
22 changes: 15 additions & 7 deletions __tests__/link.test.js
@@ -1,13 +1,21 @@
import { mount } from '@vue/test-utils';
import Link from '@/components/link';
import { createLocalVue, mount } from '@vue/test-utils';
import { VntLink } from '@/components';
import { isInstalled } from './utils';

describe('Link', () => {
let wrapper;

test('can be installed separately', () => {
const localVue = createLocalVue();
localVue.use(VntLink);

expect(isInstalled(localVue, VntLink)).toBe(true);
});

describe('by default', () => {

beforeAll(() => {
wrapper = mount(Link);
wrapper = mount(VntLink);
});

test('renders correctly', () => {
Expand All @@ -27,7 +35,7 @@ describe('Link', () => {
describe('can be disabled', () => {

beforeAll(() => {
wrapper = mount(Link, {
wrapper = mount(VntLink, {
propsData: {
disabled: true
}
Expand All @@ -47,7 +55,7 @@ describe('Link', () => {
describe('can set target', () => {

beforeAll(() => {
wrapper = mount(Link, {
wrapper = mount(VntLink, {
propsData: {
href: 'http://fluent.microsoft.com'
}
Expand All @@ -67,7 +75,7 @@ describe('Link', () => {
describe('can create proper link', () => {

beforeAll(() => {
wrapper = mount(Link, {
wrapper = mount(VntLink, {
propsData: {
href: 'http://fluent.microsoft.com'
},
Expand All @@ -86,7 +94,7 @@ describe('Link', () => {
describe('when passed other standard href attributes', () => {

test('passes correctly target attr', () => {
wrapper = mount(Link, {
wrapper = mount(VntLink, {
propsData: {
href: 'http://fluent.microsoft.com'
},
Expand Down

0 comments on commit 67dc36c

Please sign in to comment.