72 lines
2.5 KiB
JavaScript
72 lines
2.5 KiB
JavaScript
import VnLv from 'src/components/ui/VnLv.vue';
|
|
import { useClipboard } from 'src/composables/useClipboard';
|
|
|
|
describe('<VnLv />', () => {
|
|
before('login', () => {
|
|
Cypress.on('uncaught:exception', () => false);
|
|
});
|
|
const mountComponent = (opt = {}) => cy.createWrapper(VnLv, { props: { ...opt } });
|
|
|
|
it('renders with default props', () => {
|
|
mountComponent();
|
|
cy.get('.vn-label-value').should('exist');
|
|
});
|
|
|
|
it('renders label and value correctly', () => {
|
|
mountComponent({ label: 'Test Label', value: 'Test Value' });
|
|
cy.get('.label span').should('contain', 'Test Label');
|
|
cy.get('.value span').should('contain', 'Test Value');
|
|
});
|
|
|
|
it('renders boolean value as checkbox', () => {
|
|
mountComponent({ label: 'Test Label', value: true });
|
|
cy.get('.q-checkbox').should('exist');
|
|
cy.get('.q-checkbox').should('have.class', 'disabled');
|
|
});
|
|
|
|
it.only('renders info icon with tooltip', () => {
|
|
mountComponent({ info: 'Test Info' });
|
|
cy.get('.info .q-icon').should('exist');
|
|
cy.get('.info .q-icon').then((el) => {
|
|
el.trigger('mouseover');
|
|
});
|
|
// TODO
|
|
// cy.get('.q-tooltip').should('contain', 'Test Info');
|
|
});
|
|
|
|
it.only('renders copy icon and copies value', () => {
|
|
mountComponent({ value: 'Test Value', copy: true });
|
|
// cy.spy(el, 'copyText').as('copyValueText');
|
|
cy.get('.copy .q-icon').should('exist');
|
|
cy.get('.copy .q-icon').then((el) => {
|
|
el.trigger('click');
|
|
});
|
|
cy.get('.q-notification__message').should('exist');
|
|
// cy.window().focused();
|
|
// cy.window().then((win) => {
|
|
// win.navigator.clipboard.readText().then((text) => {
|
|
// console.log('Helloooo:' + text);
|
|
// });
|
|
// });
|
|
// cy.window()
|
|
// .its('navigator.clipboard')
|
|
// .invoke('readText')
|
|
// .should('equal', 'Test Value');
|
|
// cy.window().then((win) => {
|
|
// win.focus();
|
|
// cy.wrap(win.navigator.clipboard.readText()).should('equal', 'Test Value');
|
|
// });
|
|
// expect('@copyValueText').to.be.called;
|
|
});
|
|
|
|
it('renders dash if value is empty and dash is true', () => {
|
|
mountComponent({ value: '', dash: true });
|
|
cy.get('.value span').should('contain', '-');
|
|
});
|
|
|
|
it('renders value as is if dash is false', () => {
|
|
mountComponent({ value: '', dash: false });
|
|
cy.get('.value span').should('contain', '');
|
|
});
|
|
});
|