Giter VIP home page Giter VIP logo

Comments (1)

cuixiaorui avatar cuixiaorui commented on July 29, 2024

问题一:
对于前置方法 都需要假定它是没有问题的
这里的 closeCommandModal 就是前置方法
不然在写其他 test case 的时候就没法写了
因为基于前门准备数据必须要调用除了需要测试接口之外的接口
举个例子 在测试 removeTodo 的时候 就需要先调用 addTodo
如果你不假设 addTodo 是正确的话 那么 removeTodo 也就没法测

对于是调用 closeCommandModal 还是直接赋值 showCommandModal.value = false
在这个 case 中区别不大 看自己的喜好

问题二:
这里主要是为了和测试 openCommandModal 对齐
调用一个接口 然后验证其输出
从可读性上来讲 没啥问题

如果是要提前加 openCommandModal 的话 ,也挺好, 不过在测试 openCommandModal 的时候,也需要调用下 closeCommandModal 使其对齐

  it('should be open command modal', () => {
    const { openCommandModal, showCommandModal, closeCommandModal } = useCommandModal()
    closeCommandModal()

    openCommandModal()

    expect(showCommandModal.value).toBe(true)
  })

至于为什么在 beforeEach 里面都调用了 closeCommandModal 了 现在为什么还需要调用一次
是因为职责不一样, beforeEach 是为了 reset data , 而这里是明确一个前置动作

from dida.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.