Skip to content

Commit

Permalink
test: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
hunghg255 committed Sep 12, 2023
1 parent fe10b08 commit e8c4f62
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 2 deletions.
150 changes: 150 additions & 0 deletions __TEST__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,153 @@ test('CSS Aspect Ratio', () => {
});
});

test('CSS Display', () => {
const cssCode1 = `body {
display: block;
display: inline-block;
display: inline;
display: flex;
display: inline-flex;
display: table;
display: inline-table;
display: table-caption;
display: table-cell;
display: table-column;
display: table-column-group;
display: table-footer-group;
display: table-header-group;
display: table-row-group;
display: table-row;
display: flow-root;
display: grid;
display: inline-grid;
display: contents;
display: list-item;
display: none;
}`;

expect(CssToTailwind(cssCode1)).toEqual({
code: 'OK',
data: [
{
resultVal: 'block inline-block inline flex inline-flex table inline-table table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row-group table-row flow-root grid inline-grid contents list-item hidden',
selectorName: 'body',
},
],
});
});


test('CSS Object Fit', () => {
const cssCode1 = `body {
object-fit: contain;
object-fit: cover;
object-fit: fill;
object-fit: none;
object-fit: scale-down;
}`;

expect(CssToTailwind(cssCode1)).toEqual({
code: 'OK',
data: [
{
resultVal: 'object-contain object-cover object-fill object-none object-scale-down',
selectorName: 'body',
},
],
});
});

test('CSS Overflow', () => {
const cssCode1 = `body {
overflow: auto;
overflow: hidden;
overflow: clip;
overflow: visible;
overflow: scroll;
overflow-x: auto;
overflow-y: auto;
overflow-x: hidden;
overflow-y: hidden;
overflow-x: clip;
overflow-y: clip;
overflow-x: visible;
overflow-y: visible;
overflow-x: scroll;
overflow-y: scroll;
}`;

expect(CssToTailwind(cssCode1)).toEqual({
code: 'OK',
data: [
{
resultVal: 'overflow-auto overflow-hidden overflow-visible overflow-scroll overflow-x-auto overflow-y-auto overflow-x-hidden overflow-y-hidden overflow-x-visible overflow-y-visible overflow-x-scroll overflow-y-scroll',
selectorName: 'body',
},
],
});
});

test('CSS Position', () => {
const cssCode1 = `body {
position: static;
position: fixed;
position: absolute;
position: relative;
position: sticky;
}`;

expect(CssToTailwind(cssCode1)).toEqual({
code: 'OK',
data: [
{
resultVal: 'static fixed absolute relative sticky',
selectorName: 'body',
},
],
});
});


test('CSS visibility', () => {
const cssCode1 = `body {
visibility: visible;
visibility: hidden;
visibility: collapse;
}`;

expect(CssToTailwind(cssCode1)).toEqual({
code: 'OK',
data: [
{
resultVal: 'visible invisible collapse',
selectorName: 'body',
},
],
});
});

test('CSS z-index', () => {
const cssCode1 = `body {
z-index: 0;
z-index: 10;
z-index: 20;
z-index: 30;
z-index: 40;
z-index: 50;
z-index: auto;
z-index: 3;
z-index: 9;
}`;

expect(CssToTailwind(cssCode1)).toEqual({
code: 'OK',
data: [
{
resultVal: 'z-0 z-10 z-20 z-30 z-40 z-50 z-auto z-[3] z-[9]',
selectorName: 'body',
},
],
});
});

5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const propertyMap: Map<
'backface-visibility',
{
visible: '[backface-visibility:visible]',
hidden: '[backface-visibility:hidden]',
hidden: '[backface-visibility:hidden]'
},
],
[
Expand Down Expand Up @@ -2404,6 +2404,7 @@ const propertyMap: Map<
{
visible: 'visible',
hidden: 'invisible',
collapse: 'collapse',
},
],
[
Expand Down Expand Up @@ -2457,7 +2458,7 @@ const propertyMap: Map<
'40': 'z-40',
'50': 'z-50',
auto: 'z-auto',
}[val] ?? (typeof val === 'number' ? `z-[${val}]` : '')),
}[val] ?? `z-[${val}]`),
],
]);

Expand Down

0 comments on commit e8c4f62

Please sign in to comment.