Skip to content

Commit

Permalink
fix and update test snaps
Browse files Browse the repository at this point in the history
  • Loading branch information
leiyre committed Oct 29, 2024
1 parent b1e373c commit eb00e9b
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 12 deletions.
53 changes: 53 additions & 0 deletions argilla-frontend/components/base/base-date/base-date.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import { mount } from "@vue/test-utils";
import BaseDateVue from "./BaseDate.vue";
import "vue-i18n";

const mocks = {
$i18n: {
locale: "en",
},
};

const dateMocked = new Date("2023-07-19 00:00:00");
jest.useFakeTimers("modern").setSystemTime(dateMocked);
jest.mock("vue-i18n");

describe("Base Date should", () => {
test("should format date correctly", () => {
Expand All @@ -17,6 +25,11 @@ describe("Base Date should", () => {

test("should format day 1 second ago", () => {
const baseDate = mount(BaseDateVue, {
mocks: {
$i18n: {
locale: "en",
},
},
propsData: {
date: new Date("2023-07-18 23:59:59").toString(),
format: "date-relative-now",
Expand All @@ -28,6 +41,11 @@ describe("Base Date should", () => {

test("should format day 2 seconds ago", () => {
const baseDate = mount(BaseDateVue, {
mocks: {
$i18n: {
locale: "en",
},
},
propsData: {
date: new Date("2023-07-18 23:59:58").toString(),
format: "date-relative-now",
Expand All @@ -39,6 +57,11 @@ describe("Base Date should", () => {

test("should format day 2 hours ago", () => {
const baseDate = mount(BaseDateVue, {
mocks: {
$i18n: {
locale: "en",
},
},
propsData: {
date: new Date("2023-07-18 22:00").toString(),
format: "date-relative-now",
Expand All @@ -50,6 +73,11 @@ describe("Base Date should", () => {

test("should format day as yesterday", () => {
const baseDate = mount(BaseDateVue, {
mocks: {
$i18n: {
locale: "en",
},
},
propsData: {
date: new Date("2023-07-17 22:00").toString(),
format: "date-relative-now",
Expand All @@ -61,6 +89,11 @@ describe("Base Date should", () => {

test("should format day 2 days ago", () => {
const baseDate = mount(BaseDateVue, {
mocks: {
$i18n: {
locale: "en",
},
},
propsData: {
date: new Date("2023-07-16 22:00").toString(),
format: "date-relative-now",
Expand All @@ -72,6 +105,11 @@ describe("Base Date should", () => {

test("should format day last week", () => {
const baseDate = mount(BaseDateVue, {
mocks: {
$i18n: {
locale: "en",
},
},
propsData: {
date: new Date("2023-07-11 22:00").toString(),
format: "date-relative-now",
Expand All @@ -83,6 +121,11 @@ describe("Base Date should", () => {

test("should format day 2 weeks ago", () => {
const baseDate = mount(BaseDateVue, {
mocks: {
$i18n: {
locale: "en",
},
},
propsData: {
date: new Date("2023-07-01 22:00").toString(),
format: "date-relative-now",
Expand All @@ -94,6 +137,11 @@ describe("Base Date should", () => {

test("should format day last month", () => {
const baseDate = mount(BaseDateVue, {
mocks: {
$i18n: {
locale: "en",
},
},
propsData: {
date: new Date("2023-06-18 22:00").toString(),
format: "date-relative-now",
Expand All @@ -105,6 +153,11 @@ describe("Base Date should", () => {

test("should format day 2 months ago", () => {
const baseDate = mount(BaseDateVue, {
mocks: {
$i18n: {
locale: "en",
},
},
propsData: {
date: new Date("2023-05-18 22:00").toString(),
format: "date-relative-now",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

exports[`BaseTableInfo renders properly 1`] = `
<transition-stub name="fade" appear="true" actions="" deletemodalcontent="[object Object]" filterfromroute="workspace">
<div class="table-info">
<div role="table" class="table-info">
<div class="table-info__header">
<div class="table-info__item">
<div class="table-info__item__col text">
<lazy-table-filtrable-column-stub column="[object Object]" data="[object Object],[object Object]" filters="[object Object]"></lazy-table-filtrable-column-stub>
<div role="columnheader" aria-label="Table Header" class="table-info__item">
<div aria-label="Workspace" role="cell" class="table-info__item__col text">
<lazy-table-filtrable-column-stub column="[object Object]" data="[object Object],[object Object]" filters="[object Object]" aria-label="Filter column Workspace"></lazy-table-filtrable-column-stub>
</div>
</div>
</div>
<div class="table-info__body">
<ul>
<li id="data1">
<nuxt-link-stub to="() => {}" class="table-info__item"><span class="table-info__item__col text"><span class="text"><span>recognai</span>
<div aria-label="Table Body" class="table-info__body">
<ul role="rowgroup">
<li id="data1" role="row" aria-label="Row for data1">
<nuxt-link-stub to="() => {}" class="table-info__item"><span role="cell" class="table-info__item__col text"><span class="text"><span>recognai</span>
<!----></span></span></nuxt-link-stub>
</li>
<li id="data2">
<nuxt-link-stub to="() => {}" class="table-info__item"><span class="table-info__item__col text"><span class="text"><span>recognai</span>
<li id="data2" role="row" aria-label="Row for data2">
<nuxt-link-stub to="() => {}" class="table-info__item"><span role="cell" class="table-info__item__col text"><span class="text"><span>recognai</span>
<!----></span></span></nuxt-link-stub>
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`TableFiltrableColumn renders properly 1`] = `
<div class="filter__container"><button class=""><svg version="1.1" viewBox="0 0 41 40" class="svg-icon svg-fill" style="width: 16px;">
<div class="filter__container"><button class=""><svg version="1.1" viewBox="0 0 41 40" class="svg-icon svg-fill" style="width: 16px;" aria-hidden="true">
<path pid="0" d="M35.5 10A2.5 2.5 0 0033 7.5H8a2.5 2.5 0 000 5h25a2.5 2.5 0 002.5-2.5zM30.5 20a2.5 2.5 0 00-2.5-2.5H13a2.5 2.5 0 000 5h15a2.5 2.5 0 002.5-2.5zM23 27.5a2.5 2.5 0 010 5h-5a2.5 2.5 0 010-5h5z"></path>
</svg>
Workspace
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`SelectOptionsSearch renders properly 1`] = `<div class="options-search"><input type="text" autofocus="autofocus" placeholder="Search..." class="options-search__input"> <a href="#" class="options-search__clear"><svg version="1.1" viewBox="0 0 10 10" class="svg-icon svg-fill" style="width: 10px; height: 10px;"></svg></a></div>`;
exports[`SelectOptionsSearch renders properly 1`] = `<div class="options-search"><input type="text" autofocus="autofocus" placeholder="#search#" class="options-search__input"> <a href="#" class="options-search__clear"><svg version="1.1" viewBox="0 0 10 10" class="svg-icon svg-fill" style="width: 10px; height: 10px;"></svg></a></div>`;

0 comments on commit eb00e9b

Please sign in to comment.