refactor: update test components to use setup scripts
This commit is contained in:
parent
6b7d30a701
commit
e9043e6762
2 changed files with 28 additions and 50 deletions
|
|
@ -120,36 +120,26 @@
|
|||
</AppSection>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from "@nuxtjs/composition-api"
|
||||
<script setup lang="ts">
|
||||
import { computed } from "@nuxtjs/composition-api"
|
||||
import { useReadonlyStream } from "~/helpers/utils/composables"
|
||||
import { restTestResults$, setRESTTestResults } from "~/newstore/RESTSession"
|
||||
|
||||
export default defineComponent({
|
||||
setup() {
|
||||
return {
|
||||
testResults: useReadonlyStream(restTestResults$, null),
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
totalTests(): number | undefined {
|
||||
return this.testResults?.expectResults.length
|
||||
},
|
||||
failedTests(): number | undefined {
|
||||
return this.testResults?.expectResults.filter(
|
||||
(result: { status: string }) => result.status === "fail"
|
||||
).length
|
||||
},
|
||||
passedTests(): number | undefined {
|
||||
return this.testResults?.expectResults.filter(
|
||||
(result: { status: string }) => result.status === "pass"
|
||||
).length
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
clearContent() {
|
||||
setRESTTestResults(null)
|
||||
},
|
||||
},
|
||||
})
|
||||
const testResults = useReadonlyStream(restTestResults$, null)
|
||||
|
||||
const totalTests = computed(() => testResults.value?.expectResults.length)
|
||||
const failedTests = computed(
|
||||
() =>
|
||||
testResults.value?.expectResults.filter(
|
||||
(result: { status: string }) => result.status === "fail"
|
||||
).length
|
||||
)
|
||||
const passedTests = computed(
|
||||
() =>
|
||||
testResults.value?.expectResults.filter(
|
||||
(result: { status: string }) => result.status === "pass"
|
||||
).length
|
||||
)
|
||||
|
||||
const clearContent = () => setRESTTestResults(null)
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@
|
|||
</h4>
|
||||
<div class="flex flex-col pt-4">
|
||||
<TabSecondary
|
||||
v-for="(snippet, index) in snippets"
|
||||
v-for="(snippet, index) in testSnippets"
|
||||
:key="`snippet-${index}`"
|
||||
:label="snippet.name"
|
||||
active
|
||||
|
|
@ -84,29 +84,17 @@
|
|||
</AppSection>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from "@nuxtjs/composition-api"
|
||||
<script setup lang="ts">
|
||||
import { useTestScript } from "~/newstore/RESTSession"
|
||||
import testSnippets from "~/helpers/testSnippets"
|
||||
|
||||
export default defineComponent({
|
||||
setup() {
|
||||
const testScript = useTestScript()
|
||||
const testScript = useTestScript()
|
||||
|
||||
const useSnippet = (script: string) => {
|
||||
testScript.value += script
|
||||
}
|
||||
const useSnippet = (script: string) => {
|
||||
testScript.value += script
|
||||
}
|
||||
|
||||
const clearContent = () => {
|
||||
testScript.value = ""
|
||||
}
|
||||
|
||||
return {
|
||||
testScript,
|
||||
snippets: testSnippets,
|
||||
useSnippet,
|
||||
clearContent,
|
||||
}
|
||||
},
|
||||
})
|
||||
const clearContent = () => {
|
||||
testScript.value = ""
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue